<?php
class ZpMucchaBcsController extends AppController {

	var $name = 'ZpMucchaBcs';

	function index() {
		$this->ZpMucchaBc->recursive = 0;
		$this->set('zpMucchaBcs', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid zp muccha bc', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('zpMucchaBc', $this->ZpMucchaBc->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->ZpMucchaBc->create();
			if ($this->ZpMucchaBc->save($this->data)) {
				$this->Session->setFlash(__('The zp muccha bc has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The zp muccha bc could not be saved. Please, try again.', true));
			}
		}
		$ctrinhs = $this->ZpMucchaBc->Ctrinh->find('list');
		$bcs = $this->ZpMucchaBc->Bc->find('list');
		$chiphis = $this->ZpMucchaBc->Chiphi->find('list');
		$noidungs = $this->ZpMucchaBc->Noidung->find('list');
		$this->set(compact('ctrinhs', 'bcs', 'chiphis', 'noidungs'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid zp muccha bc', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->ZpMucchaBc->save($this->data)) {
				$this->Session->setFlash(__('The zp muccha bc has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The zp muccha bc could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->ZpMucchaBc->read(null, $id);
		}
		$ctrinhs = $this->ZpMucchaBc->Ctrinh->find('list');
		$bcs = $this->ZpMucchaBc->Bc->find('list');
		$chiphis = $this->ZpMucchaBc->Chiphi->find('list');
		$noidungs = $this->ZpMucchaBc->Noidung->find('list');
		$this->set(compact('ctrinhs', 'bcs', 'chiphis', 'noidungs'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for zp muccha bc', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->ZpMucchaBc->delete($id)) {
			$this->Session->setFlash(__('Zp muccha bc deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Zp muccha bc was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
